//
// Created by 啊汤哥 on 2025/9/15.
//
#define  MaxSize 10
typedef  struct {
    int data[MaxSize];
    int front,rear;
}SqQueue;

void InitQueue(SqQueue &q) {
    q.front = q.rear = 0;

}

bool EmptyQueue(SqQueue q) {
    if (q.front == q.rear) {
        return true;
    }
    return false;
}

bool isFull( SqQueue q) {
    return (q.rear+1) % MaxSize == q.front;
}

// 插入队列
bool EnQueue(SqQueue &q, int x) {
    // 判断是否已经满了
    if (isFull(q)) {
        return false;
    }
    q.data[q.rear] = x;
    q.rear = (q.rear+1) % MaxSize;
    return true;
}
// 出队列 --
bool DeQueue(SqQueue &q, int &x) {
    if (EmptyQueue(q)) {
        return false;
    }
    x = q.data(q.front);
    q.front = (q.front+1) % MaxSize;
    return true;
}